import {
    fileURLToPath,
    URL
} from 'node:url'

import {
    defineConfig
} from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue()],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src',
                import.meta.url))
        }
    },
    server: {
        proxy: {
            "/api": {
                // http://localhost:5173/api/course/login---> http://localhost:8088/course/login
                target: 'http://localhost:8088', // http://127.0.0.1:5173/api/接口
                // 允许跨域
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, "") // 重写路径，把路径变成空字符
            },
        }
    }
})
